<template>
    <div class="prulist">
        <van-search v-model="value" shape="round" background="none" placeholder="请输入搜索关键词">
            <template #left-icon>
                <img src="../../../assets/首页_slices/Vector.png" alt="">
            </template>
        </van-search>
        <div class="content">
            <!-- <div class="banner">
        <img src="" alt="">
      </div> -->
            <van-swipe class="banner" :autoplay="3000" lazy-render>
                <van-swipe-item v-for="item in Slides" :key="item.id">
                    <img style="width: 100%;height: 100%" :src="item.image" alt=""></van-swipe-item>
            </van-swipe>
            <div class="list">
                <div class="listTit">
                    <!-- <div class="titOficon"></div>
                    <div class="icon-tit">
                        商品推荐
                    </div> -->
                </div>
                <div class="listItems">
                    <div class="items">
                        <div class="listItem" v-for="item in productlist" :key="item.id" @click="routerTo(item)">
                            <div class="shopImg">
                                <van-image fit="cover" style="width: 100%;height: 100%;border-radius: 5px 5px 0 0;"
                                    :src="item.image" alt=""></van-image>
                                <!-- <img style="width: 100%;height: 100%;border-radius: 5px 5px 0 0;" :src="item.image"
                                    alt=""> -->
                            </div>
                            <div class="pre">
                                <div class="shopT">
                                    {{ item.name }}
                                </div>
                                <div class="shopP">{{ item.intro }}</div>
                                <div class="shopPrice">
                                    <span>￥</span>
                                    {{ item.member_price }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRouter, useRoute } from "vue-router";
import { productlists, getSlides, getDynamics } from '../../../api/index'
export default {
    name: "prulist",
    setup() {
        const router = useRouter();
        const route = useRoute();
        const value = ref('');
        const Slides = ref([]);
        const dynamics = ref([]);
        const productlist = ref([]);

        const routerTo = (item: any) => router.push({
            path: '/home/productdetail/' + item.id,
            params: item
        })
        onMounted(() => {
            getSlides().then(res => {
                Slides.value = res.data
            })
            // 在这里可以执行DOM操作或数据请求
            productlists({ page_size: 10, field: "is_recom", category_id: route.params.id }).then(res => {
                console.log(res.data)
                productlist.value = res.data.data
            })
        })
        return { value, Slides, dynamics, productlist, routerTo };
    },
};
</script>

<style scoped lang="less">
.prulist {
    padding: 60px 15px;
    margin: 0 auto;
    background-image: url(../../../assets/首页_slices/homeBgk.png);
    background-repeat: no-repeat;
    background-position: top left;
    background-size: 375px 250px;
    width: calc(100vw-30px);
    height: 100vh;
    background-color: #F8F9FC;

    .van-search {
        & :deep(.van-search__content--round) {
            border-radius: 10px 10px 10px 10px;
        }

        height: 34px;
        background: #FFFFFF;

        & :deep(.van-cell__value--alone) {
            font-size: 12px;
            color: #979797;
        }

        .van-field__left-icon {
            img {
                width: 13px;
                height: 13px;
            }
        }
    }

    // background: linear-gradient(179deg, #4F93F9 0%, rgba(139, 224, 247, 0) 100%);
    // border-radius: 0px 0px 0px 0px;
    .content {
        margin-top: 20px;

        .banner {
            width: 100%;
            height: 131px;
            border-radius: 10px 10px 10px 10px;
            background: blue;
            color: white;
            line-height: 130px;
        }

        .tit {
            width: 100%;
            height: 53px;
            background: #FFFFFF;
            border-radius: 8px 8px 8px 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-sizing: border-box;
            padding: 7px 13px;
            margin-top: 20px;

            .icon {
                width: 30px;
                height: 40px;
            }

            .con {
                font-size: 12px;
                color: #3D3D3D;
            }

            .van-button {
                width: 80px;
                height: 26px;
                border-radius: 347px 347px 347px 347px;
                font-size: 12px;
                color: #FFFFFF;
            }
        }

        .tabs {
            display: flex;
            justify-content: space-between;

            .tab {
                width: 167px;
                height: 89px;
                margin: 17px auto;
                background: #FFFFFF;
                border-radius: 6px 6px 6px 6px;
                padding: 20px 14px;
                display: flex;
                justify-content: space-between;
                box-sizing: border-box;
                align-items: center;

                .left {
                    display: flex;
                    justify-content: space-between;
                    flex-direction: column;

                    p {
                        margin: 0;
                        padding: 0;
                        font-size: 12px;
                        color: #666666;
                        text-align: left;

                        img {
                            width: 5px;
                            height: 9px;
                            margin-left: 12px;
                        }

                        &:nth-child(1) {
                            font-size: 16px;
                            color: #3D3D3D;
                            margin-bottom: 16px;
                        }
                    }
                }

                .right {
                    width: 40px;
                    height: 40px;
                }
            }
        }

        .list {
            .listTit {
                display: flex;
                justify-content: flex-start;
                align-items: center;
                margin-bottom: 12px;

                .titOficon {
                    width: 6px;
                    height: 18px;
                    background: linear-gradient(143deg, #0A84FF 0%, #0A7EF3 100%);
                    border-radius: 347px 347px 347px 347px;
                    margin-right: 9px;
                }

                .icon-tit {
                    font-weight: 400;
                    font-size: 16px;
                    color: #3D3D3D;
                }
            }

            .listItems {
                margin-top: 16px;

                .items {
                    display: flex;
                    justify-content: space-between;
                    flex-wrap: wrap;

                    .listItem {
                        width: 48%;
                        height: 183px;
                        background: #FFFFFF;
                        border-radius: 5px 5px 5px 5px;
                        display: flex;
                        flex-direction: column;
                        margin-bottom: 16px;

                        .shopImg {
                            width: 100%;
                            height: 106px;
                            border-radius: 5px 5px 0px 0px;

                            :deep(.van-image__img) {
                                border-radius: 5px 5px 0px 0px;
                            }
                        }

                        .pre {
                            flex: 1;
                            display: flex;
                            flex-direction: column;
                            align-items: flex-start;
                            justify-content: space-around;
                            margin: 7px;
                            text-align: left;

                            .shopT {
                                font-weight: 700;
                                font-size: 13px;
                                color: #343434;
                            }

                            .shopP {
                                font-size: 11px;
                                color: #666666;
                            }

                            .shopPrice {
                                span {
                                    font-size: 12px;
                                }

                                font-weight: 700;
                                font-size: 15px;
                                /* 根据需要设置字体大小 */
                                background: linear-gradient(49.56276305112369deg, #EB4A4A 0%, #EA7A7A 100%);
                                background-clip: text;
                                color: transparent;
                                /* 使文本颜色透明，以显示背景渐变 */
                                display: inline-block;
                                /* 确保背景渐变只应用于文本 */
                            }
                        }
                    }
                }
            }
        }
    }
}
</style>